function jump() {
    let canvas = document.getElementById("_canvas");
    let ctx = canvas.getContext("2d");
    let engine = new Engine(ctx);
    let layer = new Layer(ctx);

    layer.create = function () {
        let axis = new CoordinateObject();
        layer.addObject(axis);

        DrawUtil.drawText(layer, 600, 100, 'A-左 D-右 空格-跳');

        function createWalls() {
            let walls = [];
            for (let i = 0; i < 9; i++) {
                let wall = new RectObject();
                wall.width = ctx.canvas.width - i * 100;
                wall.y = ctx.canvas.height - (i + 1) * 50;
                wall.height = 50;
                wall.x = 10;
                wall.addComponent(new GameComponent.Tip('wall_' + i));
                layer.addObject(wall);
                walls.push(wall);
            }

            let wall9 = new RectObject();
            wall9.width = ctx.canvas.width - 9 * 100;
            wall9.y = ctx.canvas.height - 9 * 50 - 200;
            wall9.height = 200;
            wall9.x = 10;
            wall9.addComponent(new GameComponent.Tip('wall_10'));
            layer.addObject(wall9);
            walls.push(wall9);



            return walls;
        }

        let walls = createWalls();

        let polygon = new PolygonObject();
        polygon.radius = 50;
        polygon.x = 400;
        polygon.y = 100;
        polygon.degeCount = 4;
        // polygon.rotation = Math.PI * 2 / 7;
        polygon.addComponent(new GameComponent.AxisDottedLine());
        polygon.addComponent(new GameComponent.MouseDrag());
        polygon.addCollisionEvent(walls, function (event) {
            console.log('碰撞上了');
        });
        polygon.addComponent(new GameComponent.Tip('三边形'));

        function mettingOnece(walls) {
            for (let wall of walls) {
                if (CollisionUtil.metting(polygon, wall)) {
                    return wall;
                }
            }
        }

        const GRAVITY_VALUE = 12;
        let gravity = GRAVITY_VALUE;
        let speed = 0;
        let _xspeed = 20;
        let JUMP_SPEED = -50;
        let mettingGround = false;
        let jumpTimes = 2;
        polygon.update = function (delta) {
            let xmove = 0;
            if (Input.keybord_down_check('A')) {
                xmove = 0 - _xspeed * delta;
            }
            if (Input.keybord_down_check('D')) {
                xmove = _xspeed * delta;
            }
            if (xmove != 0) {
                this.x += xmove;
                let mettingWall = mettingOnece(walls);
                if (mettingWall) {
                    this.x -= xmove;
                    let sign = Math.sign(xmove);
                    let absXMove = Math.abs(xmove);
                    for (let i = 0; i < absXMove; i++) {
                        let inc = sign * Math.min(1, absXMove - sign * i);
                        this.x += inc;
                        CollisionUtil.metting(polygon, mettingWall);
                        if (CollisionUtil.metting(polygon, mettingWall)) {
                            this.x -= inc;
                            break;
                        }
                    }
                } else {
                    gravity = 9.8;
                }
            }
            let speedInc = delta * gravity;
            let ymove = speed * delta + delta * speedInc / 2;
            this.y += ymove;
            let mettingWall = mettingOnece(walls);
            if (mettingWall) {
                this.y -= ymove;
                let sign = Math.sign(ymove);
                let absYMove = Math.abs(ymove);
                for (let i = 0; i < absYMove; i++) {
                    let inc = sign * Math.min(1, absYMove - sign * i);
                    this.y += inc;
                    if (CollisionUtil.metting(polygon, mettingWall)) {
                        //y-1不实际碰到，避免水平检测的时候检查错误
                        this.y -= inc;
                        break;
                    }
                }
                mettingGround = true;
                jumpTimes = 2;
                speed = 0;
                gravity = 0;
            } else {
                speed += speedInc;
            }
            //没有按下起跳键空格
            if (!Input.keybord_down_check(' ')) {
                return;
            }
            //起跳次数超过限制
            if (jumpTimes <= 0) {
                return;
            }
            //正在朝上飞，不能再次起跳
            if (speed < 0) {
                return;
            }
            if (!mettingGround) {

            }
            console.log('第 ' + jumpTimes + ' 跳');
            speed = JUMP_SPEED;
            gravity = GRAVITY_VALUE;
            mettingGround = false;
            jumpTimes--;
        }
        layer.addObject(polygon);
    }
    engine.addLayer(layer);
    engine.run();
    return engine;
}